// Define the Data Structure that is used for a sheet

/****************************************
* Define the class for Sheets
***/
typedef	BYTE ModifiedField;	// 8 bits
#define CELL_MF_ALL			0xFF
#define	CELL_MF_CONTENT		0x01
#define CELL_MF_STYLE		0x02


class Sheet
{
private:
	RowHeader* pcRowHead;
	ColHeader* pcColumnHead;
	void modifyRowNum(RowHeader* pRowStart, bool IsIncrease = true);
	void modifyColNum(ColHeader* pColStart, bool IsIncrease = true);
	void deleteRowHeader(ROW_NUM iRow);
	void deleteColHeader(COL_NUM iCol);
	void deleteRowHeader(RowHeader* pcRowHeader);
	void deleteColHeader(ColHeader* pcColHeader);
	void deleteCell(CellNode* pLeftCell, CellNode* pAboveCell);
	bool modifyCell(ROW_NUM iRow, COL_NUM iColumn, const Cell& objCell, ModifiedField field, MemState& mem, bool remove = false);
public:
	bool ModifyCellContent(ROW_NUM iRow, COL_NUM iColumn, const wstring& strContent, MemState& mem, bool remove = false);
	Cell* FindCell(ROW_NUM iRow, COL_NUM iColumn);
	Cell* AddCell(ROW_NUM iRow, COL_NUM iColumn);
	void RemoveCell(ROW_NUM iRow, COL_NUM iColumn);
	ColHeader* GetColHead(){return pcColumnHead;}
	RowHeader* GetRowHead(){return pcRowHead;}
	// Add/Remove a Row/Column
	RowHeader* AddRowHeaderNode(ROW_NUM iRow, bool insert= false);
	ColHeader* AddColHeaderNode(COL_NUM iColumn, bool insert= false);
	RowHeader* AddRow(ROW_NUM iRow);
	ColHeader* AddColumn(COL_NUM iColumn);
	void RemoveRow(ROW_NUM iRow);
	void RemoveColumn(COL_NUM iColumn);
	// Width/Height
	int SetRowHeight(ROW_NUM iRow, int Height);
	int SetColWidth(COL_NUM iCol, int Width);
	// OutPut
	void OutPutRegion(ROW_NUM iRow_s, ROW_NUM iRow_e, COL_NUM iCol_s, COL_NUM iCol_e, wstring & buf, const wstring & RowSplit = TEXT("\r\n"), const wstring & split = TEXT("\t"), bool needQuote = false);

	LinkedList<int>MergeTable;

	Sheet();
	~Sheet();
};